package com.awaken.content.controller;

import com.awaken.content.models.dto.DemoDTO;
import com.awaken.content.models.request.DemoRequest;
import com.awaken.content.service.impl.DemoBusinessService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

/**
 * Demo控制器
 *
 * @author bytearch
 */
@Slf4j
@RestController
@RequestMapping("/api/demo")
@RequiredArgsConstructor
@Validated
public class DemoController {

    private final DemoBusinessService demoBusinessService;

    @PostMapping("/process")
    public ResponseEntity<DemoDTO> processDemo(@RequestBody @Valid DemoRequest request) {
        log.info("收到Demo处理请求: {}", request);
        DemoDTO response = demoBusinessService.processDemo(request);
        return ResponseEntity.ok(response);
    }

    @GetMapping("/{id}")
    public ResponseEntity<DemoDTO> getDemoInfo(@PathVariable @NotNull Long id) {
        log.info("获取Demo信息: {}", id);
        DemoDTO response = demoBusinessService.getDemoInfo(id);
        return ResponseEntity.ok(response);
    }

    @GetMapping("/health")
    public ResponseEntity<String> healthCheck() {
        String status = demoBusinessService.healthCheck();
        return ResponseEntity.ok(status);
    }

    @GetMapping("/test")
    public ResponseEntity<String> test() {
        return ResponseEntity.ok("Demo测试接口调用成功");
    }
}